package com.watf.functions.core;

import com.thoughtworks.selenium.Selenium;

public interface BasicFuncs {

	
	 /**
	 * This method is designed to verify if the element can be found on the page
	 * which have many sub-pages. Can be used to check if the element exists on the pages.
	 *
	 * The element you want to find must can be identified static.
	 *
	 * Author:Jester
	 */
	public boolean findElementsOnTables(Selenium selenium, String ielement) throws Exception;
	
	
	/**
	 * This method is designed to click the radio/check box if the element can be
	 * found on the page. 
	 * 
	 * Of course the radio or check box must can be identified statically.
	 * 
	 * Author:Jester
	 */
	public boolean selectElementsOnTables(Selenium selenium, String ielement)throws Exception;
	
	/**
	 * This Method is designed to check the radio/checkbox button which can't be located statically. If can be located statically,
	 * please use the selectElementsOnTables(). More effective.
	 * 
	 * But you must provided the table string and the name string.
	 * 
	 * the default search column is the second column. 
	 * 
	 * Author:Jester
	 */
	public boolean selectRadioButtonFromTable(Selenium selenium, String iTable,String iName) throws Exception;
	
	
	/**
	 * This Method is designed to check the radio/checkbox button which can't be located statically. If can be located statically,
	 * please use the selectElementsOnTables(). More effective.
	 * 
	 * But you must provided the table string and the name string.
	 * 
	 * You can specify the column if you don't want to use the second column. 
	 * 
	 * Author:Jester
	 */
	public boolean selectRadioButtonFromTable(Selenium selenium, String iTable,String iName, int iTd) throws Exception;
	
	
	/**
	 * This Method is designed to check the radio/checkbox button which can't be located statically. If can be located statically,
	 * please use the selectElementsOnTables(). More effective.
	 * 
	 * But you must provided the table string and the two names you want to locate the radio or check box.
	 * 
	 * Author:Jester
	 */
	public boolean selectRadioButtonFromTable(Selenium selenium, String iTable,String iName1, String iName2) throws Exception;
	
	
	/**
	 * This Method is designed to check if the item which can't be located statically presents in the table.
	 * If can be located statically, please use the findElementsOnTables(Selenium selenium, String ielement).
	 * 
	 * But you must provided the table string and the name string. 
	 * 
	 * The default search column is the second column.
	 * 
	 * Author:Jester
	 */
	public boolean isPresentInTable(Selenium selenium, String iTable,String iName) throws Exception;
	
	/**
	 * This Method is designed to check if the item which can't be located statically presents in the table.
	 * If can be located statically, please use the findElementsOnTables(Selenium selenium, String ielement).
	 * 
	 * But you must provided the table string and the name string. 
	 * 
	 * You can specify the column yourself.
	 * 
	 * Author:Jester
	 */
	public boolean isPresentInTable(Selenium selenium,String iTable,String iName,int i) throws Exception;
	
	/**
	 * This Method is defined to check if all the names you provided can be found in the same row.
	 * Use the first name pair as the default key word. If any of the name pairs can't be found then return false.
	 * 
	 * You must provide the name pair one after one, and make sure the fields you want to check are exist in the same row.
	 * 
	 * For example: 1=abc,2=cdf,4=ecv
	 * 
	 * Author:Jester
	 */
	public boolean isAllPresentInTable(Selenium selenium, String iTable,String iName) throws Exception;
	
	
	
	/**
	 * 1. Find the row whose name equals iName, 2. Return the text in column iTd
	 * of this row. 
	 * @param selenium
	 * @param iTable
	 * @param iName
	 * @param iTd
	 * @return
	 * @throws Exception
	 */
	
	public String getColumnText(Selenium selenium, String iTable, String iName,
			int iTd) throws Exception;
	
	
	/**
	 * This function is used for when you want to open a new page by click on locator.
	 * 
	 * It contains the waitforpagetoload() block. 
	 * 
	 * @param selenium
	 * @param locator
	 */
	public void clickAndWait(Selenium selenium, String locator);
	
	/**
	 * This function is used to open a modal dialog with 'normal' way, so solving the issue that when<b>
	 * opening an modal dialog, Selenium will hanged.
	 * @author bear
	 * @param locator The button or link to invoke the modal dialog
	 */
	public void clickAndOpenModalDialog( Selenium selenium, String locator );
	
	/**
	 * This function is used to close a modal dialog and return value to its parent page
	 * @author bear
	 * @param locator The button or link to close the modal dialog
	 * @param invoker The button or link in parent page to invoke the modal dialog. <b>
	 * 		  we need it to call showModalDialog for the second time and get return value
	 */
	public void clickAndCloseModalDialog( Selenium selenium, String locator, String invoker );
	
	/**
	 * This Method is define a handle upload function :It takes in two parameters(browser name and file path)
	 * e.g.  : browser name:( "Firefox" or "IE"),fielpath:(Tools\\gs\\upload.exe)
	 * 
	 * Author:Jack
	 */
	public void handleUpload(String browser , String filepath) throws Exception;
	/**
	 * This Method is define a handle download function
	 * e.g.  : browser name:( "Firefox" or "IE")
	 * 
	 * Author:Jack
	 */
	public void handleDownload(String browser ) throws Exception;
	

	/**
	 * Wait for a page element to appear, or the time is out
	 * 
	 * @param timeout time out in milliseconds
	 * 
	 * @author bear
	 */
	public void waitForElementAppear( Selenium selenium, String element, String timeout ) throws Exception;
	
}
